<?php
 
require_once 'vendor/autoload.php';

use 
	Doctrine\ORM\EntityManager,
	Doctrine\Common\ClassLoader,
	Doctrine\ORM\Configuration,
	Doctrine\Common\Cache\ArrayCache
//	Doctrine\ORM\Tools\Setup
	;
	
$classLoader = new ClassLoader('Doctrine\ORM', realpath(__DIR__ . '/vendor'));
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/vendor/doctrine/dbal/lib'));
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\Common', realpath(__DIR__ . '/vendor/doctrine/common/lib'));
$classLoader->register();
$classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/vendor'));
$classLoader->register();
$classLoader = new ClassLoader('app\entities', __DIR__);
$classLoader->register();
$classLoader = new ClassLoader('Proxies', __DIR__);
$classLoader->register();


// Set up caches
$config = new Configuration;
$cache = new ArrayCache;
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/app/entities"));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);

// Proxy configuration
$config->setProxyDir(__DIR__ . "/Proxies");
$config->setProxyNamespace('Proxies');
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$config->setAutoGenerateProxyClasses(true);

$paths = array("app/entities");

$isDevMode = false;

$dbParams = array(
		'driver' 	=> 'pdo_mysql',
		'user'		=>'root',
		'password' 	=> 'root',
		'dbname'	=>'zfd2'
);

//$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$em = EntityManager::create($dbParams, $config);

// Gerar as entities atraves do Banco de Dados
// orm:convert-mapping --from-database annotation ../app/entities
// doctrine orm:schema-tool:create --dump-sql
// doctrine orm:convert-mapping --from-database annotation /app/entities

?>